import React from 'react'
import { observable, action, toJS, computed } from 'mobx';
import { Toast, Tools, Bubble } from 'weaver-mobile'
import { BrowserHrmCondition } from 'weaver-mobile-page';
import * as API from '../../api/goal/goalBase';
const getLabel = Tools.getLabel;

export default class GoalShareStore {
    //共享
    @observable shareStore = new BrowserHrmCondition.Store({ route: '/goalHome/goalDetail', id: 'shareHrm' });
    @observable shareStoreValue = [];



    @action setState = (params = {}) => {
        Object.keys(params).forEach(key => {
          this[key] = params[key];
        });
      };
    

    @action("新版共享")
    setShare = (params) => {
        Toast.loading('loading', 0)
        params.workrelatetype = 1;
        params.operate = "mobileChange";
        params.data = JSON.stringify(this.shareStoreValue);
        return API.setShare(params).then(res => {
            if (res.status) {
                Bubble.success(getLabel(31439, '更新成功!'), 1)
            }
            Toast.hide()
            return res
        });
    }

    //查询共享
    @action
    getShare = (params) => {
        Toast.loading('loading', 0)
        return API.setShare(params).then(res => {
            if (res.status) {
                this.shareStoreValue = res.data
            }
            Toast.hide()
            return res
        });
    }


}